package com.ts.api.http.market.channel;

import com.gitee.apanlh.util.base.MapUtils;
import com.gitee.apanlh.web.model.vo.RequestVO;
import com.ts.api.module.api.convert.core.annotation.ApiChannelMarket;
import com.ts.api.module.api.convert.core.annotation.ApiChannelMarketConvertType;
import com.ts.api.module.api.convert.core.entity.ApiBizStatus;
import com.ts.api.module.api.convert.market.entity.ChannelMarketParameter;
import com.ts.api.module.api.convert.market.handler.ChannelMarketConvertHandler;
import com.ts.api.module.api.entity.ApiUserRequest;

import java.util.Map;

/**
 *  乐闪融-UV-前置手机号8位掩码撞库接口
 *
 *  https://www.showdoc.com.cn/yxhapi 密码123456
 *
 *  @author WJB
 */
@ApiChannelMarket(uniqueCode = "d7187c61d5634f209c55313dfc30d141", type = ApiChannelMarketConvertType.DATA_EXCHANGE_PHONE_MASK_8)
public class leShanRongPhoneMask implements ChannelMarketConvertHandler {

    @Override
    public ApiUserRequest parse(RequestVO requestVO) {
        String phone = requestVO.getStr("phone");

        ApiUserRequest apiUserRequest = new ApiUserRequest();
        apiUserRequest.setPhone(phone);
        return apiUserRequest;
    }

    @Override
    public Map<String, Object> response(ChannelMarketParameter channelMarketParameter, ApiBizStatus apiBizStatus) {
        if (apiBizStatus.hasBizSuc()) {
            return MapUtils.newHashMap(newMap -> {
                newMap.put("msg", apiBizStatus.getBizMsg());
                newMap.put("code", 200);
                newMap.put("data", channelMarketParameter.getListPhoneMd5());
            });
        }
        return MapUtils.newHashMap(newMap -> {
            newMap.put("message", apiBizStatus.getBizMsg());
            newMap.put("code", 400);
            newMap.put("data", channelMarketParameter.getListPhoneMd5());
        });
    }
}
